//package com.jomoo.css.common.core.config;
//
//import com.jomoo.css.common.core.bean.util.SpringUtil;
//import com.jomoo.css.common.core.constant.CommonConstants;
//import com.jomoo.css.common.core.constant.OrderConstants;
//import com.jomoo.css.common.core.context.ContextHolder;
//import com.jomoo.css.common.core.datainit.DataInit;
//import com.jomoo.css.common.core.datainit.DataInitEvent;
//import lombok.AllArgsConstructor;
//import lombok.SneakyThrows;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.BeansException;
//import org.springframework.boot.web.context.WebServerInitializedEvent;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.event.EventListener;
//import org.springframework.core.annotation.Order;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.Collection;
//import java.util.Comparator;
//import java.util.stream.Collectors;
//
//@Slf4j
//@Configuration
//@AllArgsConstructor
//public class DateInitRunner implements ApplicationContextAware {
//	ApplicationContext applicationContext;
//
//	@Override
//	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//		this.applicationContext = applicationContext;
//	}
//
//	@Async
//	@Order(OrderConstants.ORDER_DATA_INIT)
//	@EventListener({WebServerInitializedEvent.class, DataInitEvent.class})
//	@SneakyThrows
//	@Transactional
//	public void initRoute() {
//		log.info("initData");
//		ContextHolder.setTenantId(CommonConstants.TENANT_ID_1);
//		Collection<DataInit> dataInits = SpringUtil.getBeansOfType(DataInit.class);
//		log.info("初始化配置数据 {} ", dataInits);
//		dataInits = dataInits.stream()
//				.sorted(Comparator.comparing(DataInit::sort))
//				.collect(Collectors.toList());
//		dataInits.forEach(dataInit -> {
//			dataInit.clearData();
//			dataInit.genData();
//		});
//		ContextHolder.setTenantId(null);
//		log.debug("初始化配置数据结束 ");
//	}
//
//}